import datetime
from haystack import indexes
from goods.models import SKU


class SKUIndex(indexes.SearchIndex, indexes.Indexable):
    # 配置字段
    text = indexes.CharField(document=True, use_template=True)

    # 在那个模型类中搜索
    def get_model(self):
        return SKU

    # 指定数据集  数据源
    def index_queryset(self, using=None):
        "Used when the entire index for model is updated."
        return self.get_model().objects.filter(is_launched=True)